home *** CD-ROM | disk | FTP | other *** search
- Path: news.umbc.edu!not-for-mail
- From: schlein@umbc.edu (Jonas J. Schlein)
- Newsgroups: comp.lang.c
- Subject: Re: confusion between putchar and printf
- Date: 12 Mar 1996 13:27:15 -0500
- Organization: University of Maryland Baltimore County
- Message-ID: <4i4fm3$7ht@umbc9.umbc.edu>
- References: <4i1v2n$30o@news.azstarnet.com>
- NNTP-Posting-Host: umbc9.umbc.edu
- NNTP-Posting-User: schlein
-
- Howard Salmon <captarm@azstarnet.com> wrote:
- |> K & R (section 1.5) states that "putchar(c) prints the contents of the
- |> integer variable c as a character, usually on the screen".
- |>
- |> Here's a small program that I wrote testing putchar. Why doesn't it
- |> compile?
-
- Usually a tad of common sense helps, but here's the main problem.
- The putchar() function prints a single character while the printf()
- function is more of a general purpose printing function that can
- do lots of stuff depending on what you tell it.
-
- |> #include <stdio.h>
- |> # define A "hello world!"
-
- 'A' is a string.
-
- |> main()
- |> {
- |> int c;
- |> c = A;
-
- 'c' is an int which cannot store a string.
-
- |> putchar(A);
-
- 'A' is a string which putchar() is unable to print.
-
- |> }
- |>
- |> Thanks,
-
- Just say what you are trying to do. Do you want to print the string or
- perhaps just the first character in the string? What errors did your
- compiler give you...Most likely these identifies the line(s) the problems
- were on.
- --
- "If it wasn't for C, we would be using BASI, PASAL, and OBOL."
-
- Jonas J. Schlein (schlein@gl.umbc.edu)
-